﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace User.API.Data.Mapping
{
    public class BPFileMap
      : IEntityTypeConfiguration<BPFile>
    {
        public void Configure(EntityTypeBuilder<BPFile> builder)
        {
            //Table.
            builder.ToTable("BPFile");

            //Key.
            builder.HasKey("Id");

            //Property.
            builder.Property(t => t.Id)
              .HasColumnName("Id")
              .IsRequired();
            builder.Property(t => t.FileName)
              .HasColumnName("FileName")
                .HasMaxLength(36)
                .IsUnicode(true)
                .IsRequired();
            builder.Property(t => t.OriginPath)
              .HasColumnName("OriginPath")
                .HasMaxLength(1000)
                .IsUnicode(true)
                .IsRequired();
            builder.Property(t => t.FormatPath)
             .HasColumnName("FormatPath")
               .HasMaxLength(1000)
               .IsUnicode(true)
               .IsRequired();
            //Relation.
            builder.HasOne(t => t.AppUser)
               .WithMany(t => t.BPFiles)
               .HasForeignKey(t => t.AppUserId);


        }
    }
}
